$(document).ready(function(){
//	获取当前url参数
	$.getQueryString=function(paraname){
		var reg = new RegExp("(^|&)" + paraname + "=([^&]*)(&|$)","i");
	    var r = window.location.search.substr(1).match(reg);
	    if (r!=null){
	        return (r[2]);
	    }
	    return null;
	}
	var title = $.getQueryString("title");
	
	var year = title.substring(0,4);
	var mon = title.substring(13,15);
	var day = title.substring(24,26);
	
	title = year+"_"+mon+"_"+day;
	
	getSentimentDetail(title);
	

})
function getSentimentDetail(title){
	$.ajax({
		type:"get",
		url:'../../DailySentimentServlet?method=getReportByDate',
		data:{
			"title":title
		},
		success:function(data){
			console.log("ajaxResult:"+data);
			if(data == null){
				
			}
			var dataObj=JSON.parse(data);
			var time = dataObj.title;
		    var report = dataObj.reports;
		    
		    if(report == null){
		    	var info = JSON.parse(data).info;
		    	var infomation = $("<h4>"+ info + "</h4>");		   
		    	$("#Content").append(infomation);
		    }else{
		    	var title = $("<h3 class=\"contentTitle\">【每日舆情】" + time + "焦点浅析</h3>");
			    $("#Content").append(title);
			    
		    	var content = report[0].text;
			    console.log(content);
				var htmlContent="";
				for(var i in content)
				{
					content[i]=content[i].split(" 　　");
					for(var j in content[i])
					{
						if(content[i][j].charAt(0)=="　"&&content[i][j].charAt(1)=="　")
							htmlContent+="<p>"+content[i][j]+"</p>";
						else
							htmlContent+="<p>　　"+content[i][j]+"</p>";
						content[i][j]="<p>"+content[i][j]+"</p>";
					}
				}
				
			    
			    $.each(report,function(indexs,values){
			    	
			    	console.log(this.title);
			    	
			    	var sentiment = $("<div class=\"panel panel-default\">" +
			    			"<div class=\"panel-heading\">" + "焦点" + (indexs+1) + ":" + this.title +"</div>" +
			    			"<div class=\"panel-body\" id=\"" + indexs + "\">" +
			    			"<p style=\"color:orangered\">焦点报道：</p>" +
			    			"<p style=\"font-weight: 400\" class=\"text-justify\">&nbsp;&nbsp;&nbsp;&nbsp;" +htmlContent + "</p>" +
	//		    			"<p style=\"color:orangered\">舆情数据：</p>" +
			    			"<hr class=\"divider\" style=\"width:90%;border:1px dashed;border-color: gray\">" +
			    			"<p style=\"font-weight: 500\">样本数据来源于网络舆情监测系统&nbsp;&nbsp;取样截止时间：" + this.date + "</p>" +
			    			"<p style=\"color:orangered\">各方观点：</p></div></div></div>");
			    	$("#Content").append(sentiment);
			    	if(this.opinion != null){
				    	var opinionlist = this.opinion;
				    	var opinions;
				    	console.log("opinionlist____:"+this.opinion);
			    			 $.each(opinionlist,function(index,value){
			    				 
					    		 var opinion = $("<p style='font-weight: 400' class='text-justify'><strong>"+this.publisher+"：</strong>"+this.text[0]+"</p>");
					    		 $(".panel-body").eq(indexs).append(opinion);
					    	 });	    	
			    	}
			    });	   
		    }
		},
		error:function(){
			console.log("error");
		}
	})
}